package Stream;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Test1 {
    /*
          将数据添加到集合中,筛选"张"开头的名字,以及"张"开头的个三字的名字
         */
    public static void main(String[] args) {



    }
        //集合方法添加
    private static void methodBySet() {
        List<String>list=new ArrayList<>();
        Collections.addAll(list,"张三","李四","张三丰","张无极","王五");
        List<String>list2=new ArrayList<>();
        List<String>list3=new ArrayList<>();
        for (String s:list){
            char[] chars = s.toCharArray();
            if ('张'==chars[0]){
                    list2.add(s);
            }

        }
        for (String s:list){
            if (s.startsWith("张")){
                if (s.length()==3){
                    list3.add(s);
                }
            }

        }
        System.out.println("张开头的名字");
        for (String s:list2){
            System.out.println(s);
        }
        System.out.println("张开头,3个字名字");
        for (String s:list3){
            System.out.println(s);
        }
    }
}
